public class Test2 {
    public static void main(String[] args) {
        //StringBuilder小练习  给出一个数组如[11,22,33]  要求返回一个字符串"[11, 22, 33]"
        System.out.println(getArrayData(new int[]{11, 22, 33}));

    }

    public static String getArrayData(int [] arr){
        if (arr == null){
            return null;
        }

         StringBuilder sb = new StringBuilder();
         sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1){
                sb.append(arr[i]);
            }else {
                sb.append(arr[i]).append(", ");
            }
        }
        sb.append("]");
        return sb.toString();
    }
}
